﻿/*************************************************************************************
 * 文 件 名:   HK_Point
 * 
 * 描    述:   RoamingCam的位移点位的控制脚本
 * 
 * 版    本：  V1.0
 * 创 建 者：  谭潇杰、京产肠饭
 * 创建时间：  2022/1/28
 * 链   接：  https://gitee.com/JingChanChangFan/hk_-unity-tools
*************************************************************************************/

using UnityEngine;

public enum LookAtType
{
    Diffuse,     //不自动朝向
    ByQuaternion,  //通过四元数
    ByTarget,      //通过设置目标点
}

public class HK_Point : MonoBehaviour
{
    [Header("朝向类型：")]
    public LookAtType lookAtType;

    [Header("参考球的位置：")]
    public Vector3 lookAtPos;

    [Header("朝向四元数：")]
    public Quaternion lookAtRot = new Quaternion();

    // 位移目标点位
    public Vector3 TargetPos { get; set; }

    void Start()
    {
        HK_TeleportSelect.teleports.Add(this);
        TargetPos = transform.position;
    }

    void OnDrawGizmosSelected()
    {
        if (lookAtType == LookAtType.Diffuse)
            return;

        if (lookAtType == LookAtType.ByTarget)
        {
            Gizmos.color = Color.white;
            Gizmos.DrawSphere(lookAtPos, 0.2f);
        }

        if (lookAtType == LookAtType.ByQuaternion)
        {
            Gizmos.color = Color.blue;
            Gizmos.DrawRay(lookAtPos, lookAtRot * transform.forward);
            Gizmos.DrawSphere(lookAtPos + lookAtRot * transform.forward, 0.05f);
        }
    }
}
